﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using 聚欣订单分析.PublicClass;

namespace 聚欣订单分析
{
    public partial class hksh : System.Web.UI.Page
    {
        PLSQLClass PL = new PLSQLClass();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //update tbl_DDB set 状态='回款通过',第一笔回款日期='2018-7-23 0:00:00',第一笔回款金额=第一笔回款金额+1.00 where ID=2018142
            List<object> IDValues = this.ASPxGridView1.GetSelectedFieldValues("ID");
            List<object> DDID = this.ASPxGridView1.GetSelectedFieldValues("DDID");
            List<object> HKBS = this.ASPxGridView1.GetSelectedFieldValues("HKBS");
            List<object> HKRQ = this.ASPxGridView1.GetSelectedFieldValues("HKRQ");
            List<object> HKJE = this.ASPxGridView1.GetSelectedFieldValues("HKJE");
            for (int i = 0; i < IDValues.Count; i++)
            {
                string strSQL1 = "";
                if (HKBS[i].ToString() == "1")
                {
                    strSQL1 = "update tbl_DDB set 状态='回款通过',第一笔回款日期='" + HKRQ[i].ToString() + "',第一笔回款金额=第一笔回款金额+" + HKJE[i].ToString() + ",尾款=尾款-" + HKJE[i].ToString() + " where ID=" + DDID[i].ToString();
                }
                else
                {
                    strSQL1 = "update tbl_DDB set 状态='回款通过',第二笔回款日期='" + HKRQ[i].ToString() + "',第二笔回款金额=第二笔回款金额+" + HKJE[i].ToString() + ",尾款=尾款-" + HKJE[i].ToString() + " where ID=" + DDID[i].ToString();
                }
                string strSQL2 = "update tbl_HKSH set zt=1,BZ='" + ASPxMemo1.Text.Trim() + "' where ID=" + IDValues[i].ToString();
                PL.ExecuteSqlWithGoUseTran(strSQL2 + "go" + strSQL1);
            }
            JsHelper.AlertAndRedirect("审核成功", "hksh.aspx");
        }

        protected void bthTh_Click(object sender, EventArgs e)
        {
            List<object> IDValues = this.ASPxGridView1.GetSelectedFieldValues("ID");
            List<object> DDID = this.ASPxGridView1.GetSelectedFieldValues("DDID");
            for (int i = 0; i < IDValues.Count; i++)
            {
                string strSQL1 = "update tbl_DDB set 状态='回款回退' where ID=" + DDID[i].ToString();
                string strSQL2 = "update tbl_HKSH set zt=2,BZ='" + ASPxMemo1.Text.Trim() + "' where ID=" + IDValues[i].ToString();
                PL.SqlGetData(strSQL1);
                PL.SqlGetData(strSQL2);
            }
            JsHelper.AlertAndRedirect("审核成功", "hksh.aspx");
        }
    }
}
